# coding: utf-8
from sqlalchemy import CHAR, Column, JSON, String, TIMESTAMP, Table, Text, text, MetaData
from sqlalchemy.dialects.mysql import ENUM, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, TEXT, TINYINT, VARCHAR
from ..database import db,serialize


class Ad(db.Model):
    __tablename__ = 'ads'

    id = Column(INTEGER(10), primary_key=True)
    pos_id = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='位置ID')
    title = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("''"), comment='标题')
    thumb = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("''"), comment='图片')
    url = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("''"), comment='链接')
    starttime = Column(TIMESTAMP, comment='开始时间')
    endtime = Column(TIMESTAMP, comment='结束时间')
    sort = Column(MEDIUMINT(8), nullable=False, server_default=text("'0'"), comment='排序')
    status = Column(TINYINT(1), nullable=False, server_default=text("'1'"), comment='状态，1正常0关闭')
    created_at = Column(TIMESTAMP)
    updated_at = Column(TIMESTAMP)

